package org.goobs.logic;

public class Implication {

	private static int NEXT_TYPE = 0;
	
	//--Triger
	private int trigType = -1;
	private int trigIndex;
	private int trigOutof;
	
	//--Pass on
	private int passType;
	private int passIndex;
	private int passOutof;
	
	private Predicate passTo;
	
	
	protected Implication(int index, int outOf, Predicate passTo){
		this(NEXT_TYPE, index, outOf, passTo);
	}
	
	protected Implication(int trigIndex, int trigOutof, int passIndex, int passOutof, Predicate passTo){
		this(NEXT_TYPE++, trigIndex, trigOutof, NEXT_TYPE++, passIndex, passOutof, passTo);
	}
	
	protected Implication(int type, int index, int outOf, Predicate passTo){
		this(-1, -1, -1, type, index, outOf, passTo);
	}
	
	private Implication(int trigType, int trigIndex, int trigOutof, int passType, int passIndex, int passOutof, Predicate passTo){
		this.trigType = trigType;
		this.trigIndex = trigIndex;
		this.trigOutof = trigOutof;
		this.passType = trigType;
		this.passIndex = passIndex;
		this.passOutof = passOutof;
		this.passTo = passTo;
	}
	
	
	public static Implication[] create(int passNum, Predicate passTo){
		Implication[] rtn = new Implication[passNum];
		int passType = NEXT_TYPE++;
		for(int i=0; i<passNum; i++){
			rtn[i] = new Implication(passType, i, passNum, passTo);
		}
		return rtn;
	}
	
	public static Implication[][] create(int trigNum, int passNum, Predicate passTo){
		Implication[][] rtn = new Implication[trigNum][];
		int trigType = NEXT_TYPE++;
		for(int i=0; i<trigNum; i++){
			rtn[i] = new Implication[passNum];
			int passType = NEXT_TYPE++;
			for(int j=0; j<passNum; j++){
				rtn[i][j] = new Implication(trigType, i, trigNum, passType, j, passNum, passTo);
			}
		}
		return rtn;
	}
	
	
}
